@file:JvmName("LogUtils")

package com.yl.androidutilscenter.utils

import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.FormatStrategy
import com.orhanobut.logger.Logger
import com.orhanobut.logger.PrettyFormatStrategy


/**
 * @author
 * @description:logcat中打印信息
 * @date :2024/3/8
 * @version 1.0.0
 */
object LogUtils {

    fun initLog(tag: String = "AndroidUtilCenter") {
        val formatStrategy: FormatStrategy = PrettyFormatStrategy.newBuilder()
            .showThreadInfo(false) // (Optional) Whether to show thread info or not. Default true
            .methodCount(0) // (Optional) How many method line to show. Default 2
            .methodOffset(7) // (Optional) Hides internal method calls up to offset. Default 5
//            .logStrategy(customLog) // (Optional) Changes the log strategy to print out. Default LogCat
            .tag(tag) // (Optional) Global tag for every log. Default PRETTY_LOGGER
            .build()
        Logger.addLogAdapter(object : AndroidLogAdapter(formatStrategy) {
            override fun isLoggable(priority: Int, tag: String?): Boolean {
                return super.isLoggable(priority, tag)
//                return BuildConfig.DEBUG
            }
        })
    }

    @JvmStatic
    fun i(message: String) {
        Logger.i(message)
    }

    @JvmStatic
    fun e(message: String) {
        Logger.e(message)
    }

    @JvmStatic
    fun d(message: String) {
        Logger.d(message)
    }

    @JvmStatic
    fun d(message: Any) {
        Logger.d(message)
    }

    @JvmStatic
    fun v(message: String) {
        Logger.v(message)
    }

    @JvmStatic
    fun w(message: String) {
        Logger.w(message)
    }

    @JvmStatic
    fun json(message: String) {
        Logger.json(message)
    }

    @JvmStatic
    fun xml(message: String) {
        Logger.xml(message)
    }

}